def rot13 text
  return text.each_byte.inject("") do
    |str,n| 
    # Checking we have a lowercase letter.
    # We don't want to "downcase" as rot13(rot13) would alter 
    # the original message
    if n >= 97 and n <= 122
      # 97 is used as the offset, as this is the position of the letter 'a'
      # in the ASCII table, see: puts "a"[0]
      # Add 13 modulo 26 to return at the beginning of the alphabet.
      str.concat((((n+13)-97)%26)+97)
    else 
      str.concat(n) # else return "as is".
  end
end
# Apply ROT13 to a piece of text.
puts rot13(<<TEXT)
this is some text to convert
TEXT

# And verify that applying it again gives the original message!
puts rot13(rot13(<<TEXT)
this is some text to convert
TEXT
)